from login.settings import SECRET_KEY
import jwt

class MJwt:
    def __init__(self):
        self.secret_key = SECRET_KEY
    # 加密
    def jwt_encode(self, data):
        return jwt.encode(data, self.secret_key,algorithm="HS256")
    # 解密
    def jwt_decode(self, token):
        return jwt.decode(token, self.secret_key, algorithms="HS256")

# 单例模式，保证全局只有一个对象
mjwt = MJwt()